# __author: iamironman
from rest_framework import serializers
from .models import CourseCategory


class CourseCategoryModelSerializer(serializers.ModelSerializer):
    class Meta:
        model = CourseCategory
        fields = ('id', 'name')


from .models import Teacher


class TeacherModelSerializer(serializers.ModelSerializer):
    class Meta:
        model = Teacher
        fields = ('id', 'name', 'title', 'signature')


class TeacherDetailModelSerializer(serializers.ModelSerializer):
    class Meta:
        model = Teacher
        fields = ('id', 'name', 'title', 'role', 'signature', 'image', 'brief')


from .models import CourseLesson


class CourseLessonModelSerializer(serializers.ModelSerializer):
    class Meta:
        model = CourseLesson
        fields = ('id', 'name', 'free_trail', 'duration', 'section_link')


from .models import CourseChapter


class CourseChapterModelSerializer(serializers.ModelSerializer):
    coursesections = CourseLessonModelSerializer(many=True)

    class Meta:
        model = CourseChapter
        fields = ('id', 'name', 'coursesections', 'chapter')


from .models import Course


class CourseModelSerializer(serializers.ModelSerializer):
    teacher = TeacherModelSerializer()

    # coursechapters = CourseChapterModelSerializer(many=True)

    class Meta:
        model = Course
        fields = ('id', 'name', 'course_img', 'students', 'lessons', 'pub_lessons', 'price', 'teacher', 'lesson_list',
                  'get_course_price', 'get_course_discount_type')


class CourseDetailModelSerializer(serializers.ModelSerializer):
    teacher = TeacherDetailModelSerializer()

    class Meta:
        model = Course
        fields = (
            'id', 'name', 'video', 'course_img', 'students', 'lessons', 'pub_lessons', 'price', 'teacher',
            'course_level', 'brief', 'get_course_price', 'get_course_discount_type', 'has_time')
